package com.chainyoung.common.appcommon.hdwallet;

import com.chainyoung.common.appcommon.entity.Version;
import com.chainyoung.common.base.BaseResponse;

import java.io.IOException;
import java.util.TreeMap;
import java.util.concurrent.TimeUnit;

import io.reactivex.Flowable;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.ResponseBody;
import retrofit2.http.Field;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Query;

/**
 * 以太坊请求
 */
public interface EtherscanService {

    /**
     * 余额
     * @param addr
     * @return
     */
    @GET(WalletServerConstant.GET_SINGLE_BALANCE)
    Flowable<ResponseBody> getBalance(@Query("address")String addr);



    @GET(WalletServerConstant.GET_MULTI_BALANCE)
    Flowable<ResponseBody> getMultiBalance(@Query("address")String addrs);

    /**
     * 不分页记录
     */

    @GET(WalletServerConstant.GET_ALL_NORMAL_TRANSACTION)
    Flowable<ResponseBody> getAllNormalTranscation(@Query("address")String addrs);

    /**
     * 分页记录
     */

    @GET(WalletServerConstant.GET_NORMAL_TRANSACTION_BY_PAGE)
    Flowable<ResponseBody> getNormalTranscation(@Query("address")String addrs,@Query("page")int page,@Query("offset")int pageSize);


    /**
     * 发送
     */
    @FormUrlEncoded
    @POST(WalletServerConstant.SEND_TRANSACTION)
    Flowable<ResponseBody> sendTransaction(@Field("hex")String hex);


    /**
     *  当前地址交易次数
     * @param addr
     * @return
     */
    @GET(WalletServerConstant.GET_TRANSACTION_COUNT)
    Flowable<ResponseBody> getTransactionCount(@Query("address")String addr);




    /**
     *  预估gas used gas
     * @param to
     * @return
     */
    @GET(WalletServerConstant.GET_GAS_LIMIT_ESTIMATE)
    Flowable<ResponseBody> getGasLimitEstimate(@Query("to")String to);


    /**
     * 获取gas price  Returns the current price per gas in wei.
     */
    @GET(WalletServerConstant.GET_GAS_PRICE)
    Flowable<ResponseBody> getGasPrice();



    /**
     * 获取eth price
     */
    @GET(WalletServerConstant.GET_ETH_PRICE)
    Flowable<ResponseBody> getEthPrice();


    /**
     * 获取美元对人民币汇率
     */
    @FormUrlEncoded
    @POST(WalletServerConstant.GET_RATE)
    Flowable<ResponseBody> getUsdCnyRate(@Field("from")String from,@Field("to")String to);


    /**
     * 获取以太坊地址所有代币转账记录 Get a list of "ERC20 - Token Transfer Events" by Address
     */
    @GET(WalletServerConstant.GET_ALL_TOKEN_TRANSFERS)
    Flowable<ResponseBody> getAllTokenTransfers(@Query("address")String address);



    /**
     * 获取单个代币所有转账记录 分页
     * @param contractaddress 合约地址
     * @param address 以太坊地址 传入则获取相关此地址所有记录包括 转入转出，否则不传
     */
    @GET(WalletServerConstant.GET_SINGLE_TOKEN_TRANSFER)
    Flowable<ResponseBody> getSingleTokenTransfers(@Query("contractaddress")String contractaddress,@Query("address")String address,
                                                   @Query("page")int page,@Query("offset")int offset);



    /**
     * 获取单个代币余额
     * @param contractaddress 合约地址
     * @param address 以太坊地址
     */
    @GET(WalletServerConstant.GET_TOKEN_BALANCE)
    Flowable<ResponseBody> getTokenBalance(@Query("contractaddress") String contractaddress,@Query("address")String address);





}
